package util

type BasketBallStatus int
type FBMatchStatType int
type FootBallStatus int
type BBMatchStatType int

const (
	BBUnknown       BasketBallStatus = iota // 比赛异常，说明：暂未判断具体原因的异常比赛，可能但不限于：腰斩、取消等等，建议隐藏处理
	BBNotStarted                            // 未开赛
	BBSection1                              // 第一节
	BBEndOfSection1                         // 第一节完
	BBSection2                              // 第二节
	BBEndOfSection2                         // 第二节完
	BBSection3                              // 第三节
	BBEndOfSection3                         // 第三节完
	BBSection4                              // 8 第四节
	BBOvertime                              // 加时
	BBFinish                                // 10 完场
	BBInterruptions                         // 中断
	BBCancel                                // 取消
	BBDelay                                 // 延期
	BBExceptions                            // 腰斩
	BBTBD                                   // 待定
)

const (
	FBUnknown         FootBallStatus = iota //比赛异常，说明：暂未判断具体原因的异常比赛，可能但不限于：腰斩、取消等等，建议隐藏处理
	FBNotStarted                            // 未开赛
	FBFirstHalf                             // 上半场
	FBMidfield                              // 中场
	FBSecondHalf                            // 下半场
	FBOvertime                              // 加时赛
	_                                       // 加时赛(弃用)
	FBPenaltyShootout                       // 点球决战
	FBFinish                                // 8 完场
	FBDelay                                 // 推迟
	FBInterruptions                         // 中断
	FBExceptions                            // 腰斩
	FBCancel                                // 取消
	FBTBD                                   // 待定
)
const (
	_ = iota
	FootBall
	BasketBall
)
const (
	_ = iota
	Pending
	Starting
)

var (
	FBStartingStatus = []int{
		int(FBFirstHalf),       // 上半场
		int(FBMidfield),        // 中场
		int(FBSecondHalf),      // 下半场
		int(FBOvertime),        // 加时赛
		int(FBPenaltyShootout), // 点球决战
	}
	FBPendingStatus = []int{
		int(FBNotStarted), //未开赛
	}

	BBStartingStatus = []int{
		int(BBSection1),      // 第一节
		int(BBEndOfSection1), // 第一节完
		int(BBSection2),      // 第二节
		int(BBEndOfSection2), // 第二节完
		int(BBSection3),      // 第三节
		int(BBEndOfSection3), // 第三节完
		int(BBSection4),      // 第四节
		int(BBOvertime),      // 加时
	}
	BBPendingStatus = []int{
		int(BBNotStarted), // 未开赛
	}

	SportStatus = map[int]map[int][]int{
		Pending: {
			FootBall:   FBPendingStatus,
			BasketBall: BBPendingStatus,
		},
		Starting: {
			FootBall:   FBStartingStatus,
			BasketBall: BBStartingStatus,
		},
	}
)

func (t BasketBallStatus) String() string {
	switch t {
	case BBUnknown:
		return "比赛异常"
	case BBNotStarted:
		return "未开赛"
	case BBSection1:
		return "第一节"
	case BBEndOfSection1:
		return "第一节完"
	case BBSection2:
		return "第二节"
	case BBEndOfSection2:
		return "第二节完"
	case BBSection3:
		return "第三节"
	case BBEndOfSection3:
		return "第三节完"
	case BBSection4:
		return "第四节"
	case BBOvertime:
		return "加时"
	case BBFinish:
		return "完场"
	case BBInterruptions:
		return "中断"
	case BBCancel:
		return "取消"
	case BBDelay:
		return "延期"
	case BBExceptions:
		return "腰斩"
	case BBTBD:
		return "待定"
	}
	return ""
}

func (t FootBallStatus) String() string {
	switch t {
	case FBUnknown:
		return "比赛异常"
	case FBNotStarted:
		return "未开赛"
	case FBFirstHalf:
		return "上半场"
	case FBMidfield:
		return "中场"
	case FBSecondHalf:
		return "下半场"
	case FBOvertime:
		return "加时赛"
	case FBPenaltyShootout:
		return "点球决战"
	case FBFinish:
		return "完场"
	case FBDelay:
		return "推迟"
	case FBInterruptions:
		return "中断"
	case FBExceptions:
		return "腰斩"
	case FBCancel:
		return "取消"
	case FBTBD:
		return "待定"
	}
	return ""
}

const (
	_          FBMatchStatType = iota
	FBMatching                 // 1进球
	FBCornerKick               // 2角球
	FBYellowCard               // 3黄牌
	FBRedCard                  // 4红牌
	FBBoundsBall               // 5界外球
	FBFreeKick                 // 6任意球
	FBGoalBall                 // 7球门球
	FBPenaltyKick              // 8点球
	FBReplacement              // 9换人
	FBStart                    // 10比赛开始
	FBMidfieldType             // 11中场
	FBEnd                      // 12结束
	FBHalftimeScore            // 13半场比分
	FBYellow2Red               // 15两黄变红
	FBPenaltyKickMissed        // 16点球未进
	FBOnslaught                // 17乌龙球
	FBInjuries                 // 19伤停补时
	FBShotOnTarget             // 21射正
	FBDeviated                 // 22射偏
	FBAttack                   // 23进攻
	FBDangerousAttack          // 24危险进攻
	FBPossession               // 25控球率
	FBExtraTimeOver            // 26加时赛结束
	FBPenaltyShootOver         // 27点球大战结束
	FBVar                      // 28VAR(视频助理裁判)
	FBPso                      // 29点球(点球大战)(type_v2字段返回)
	FBPsoMiss                  // 30点球未进(点球大战)(type_v2字段返回
)

const (
	_ BBMatchStatType = iota

	BB3PointGoals          //1 3分球进球数
	BB2PointGoals          //2 2分球进球数
	BBPenaltyGoals         //3 罚球进球数
	BBRemainingPauses      //4 剩余暂停数
	BBFoulCount            //5 犯规数
	BBFreeThrowPercentage  //6 罚球命中率
	BBTotalRemainingPauses //7 总暂停数
)

var (
	FBStatNameMap = map[FBMatchStatType]string{
		FBMatching:          "进球",
		FBCornerKick:        "角球",
		FBYellowCard:        "黄牌",
		FBRedCard:           "红牌",
		FBBoundsBall:        "界外球",
		FBFreeKick:          "任意球",
		FBGoalBall:          "球门球",
		FBPenaltyKick:       "点球",
		FBReplacement:       "换人",
		FBStart:             "比赛开始",
		FBMidfieldType:      "中场",
		FBEnd:               "结束",
		FBHalftimeScore:     "半场比分",
		FBYellow2Red:        "两黄变红",
		FBPenaltyKickMissed: "点球未进",
		FBOnslaught:         "乌龙球",
		FBInjuries:          "伤停补时",
		FBShotOnTarget:      "射正",
		FBDeviated:          "射偏",
		FBAttack:            "进攻",
		FBDangerousAttack:   "危险进攻",
		FBPossession:        "控球率",
		FBExtraTimeOver:     "加时赛结束",
		FBPenaltyShootOver:  "点球大战结束",
		FBVar:               "VAR(视频助理裁判)",
		FBPso:               "点球(点球大战)",
		FBPsoMiss:           "点球未进(点球大战)",
	}
	BBStatNameMap = map[BBMatchStatType]string{
		BB3PointGoals:          "3分球进球数",
		BB2PointGoals:          "2分球进球数",
		BBPenaltyGoals:         "罚球进球数",
		BBRemainingPauses:      "剩余暂停数",
		BBFoulCount:            "犯规数",
		BBFreeThrowPercentage:  "罚球命中率",
		BBTotalRemainingPauses: "总暂停数",
	}
)

func (b BBMatchStatType) String() string {
	s, ok := BBStatNameMap[b]
	if !ok {
		return "未知"
	}
	return s
}

func (f FBMatchStatType) String() string {
	s, ok := FBStatNameMap[f]
	if !ok {
		return "未知"
	}
	return s
}
